{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>AI Peng资源分享网</title>
    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="{% static 'css/index.css' %}">
</head>
<body>
<!-- 导航条开始 -->
{% include 'common/_nav.html' %}
<!-- 导航条结束 -->

<!-- 布局 -->
<div class="container">
    <div class="row">
        <div style="margin-top: 60px;">
            <!-- 中间开始 -->
            <div class="col-md-9">
                <ul class="list-group">
                    {% if article_list %}
                        {% for article in  article_list %}
                            {#单篇文章开始#}
                            <li class="list-group-item">
                                <div class="panel panel-default">
                                    <!-- Default panel contents -->
                                    <div class="panel-heading">
                                        <a href="{% url 'article:detail' %}?id={{ article.id }}"
                                           style="text-decoration: none; color: black;">
                                            <h3 id="articleTitle">{{ article.title }}</h3>
                                        </a>
                                    </div>
                                    <div class="panel-body">
                                        <div>{{ article.info }}</div>
                                    </div>
                                    <div class="panel-footer" id="articleFooter">
                                        <span>
                                        作者：{{ article.username }}
                                        </span>
                                        <span class="ml10">
                                        发布日期：{{ article.create_time }}
                                        </span>
                                        <span class="ml10">
                                            <span class="glyphicon glyphicon-thumbs-up a-hover" aria-hidden="true"
                                                  onclick="clickGood({{ article.id }})"></span>
                                            <span id="goodNumSpan{{ article.id }}">{{ article.good_num }}</span>
                                        </span>
                                        <span class="ml10">
                                            <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
                                            <span>{{ article.view_num }}</span>
                                        </span>
                                    </div>
                                </div>
                            </li>
                            {#单篇文章结束#}
                        {% endfor %}
                    {% else %}
                        {#单篇文章开始#}
                        <li class="list-group-item">
                            <div class="panel panel-default">
                                <div style="padding: 20px;">暂无博客，请 <a href="{% url 'user:register' %}">注册</a> 后添加您的第一篇博客
                                </div>
                            </div>
                        </li>
                        {#单篇文章结束#}
                    {% endif %}
                </ul>

                <div style="text-align: center;">
                    <!-- 文章分页开始 -->
                    <nav aria-label="Page navigation" style="margin-bottom: 80px;">
                        <ul class="pagination">
                            {% if page.has_previous %}
                                <li>
                                    <a href="?p={{ page.previous_page_number }}" aria-label="Previous">
                                        <span aria-hidden="true">上一页</span>
                                    </a>
                                </li>
                            {% else %}
                                <li class="disabled">
                                    <a href="#" aria-label="Previous">
                                        <span aria-hidden="true">上一页</span>
                                    </a>
                                </li>
                            {% endif %}
                            {% for middle in middle_page %}
                                {% ifequal current_page middle %}
                                    <li class="active"><a href="?p={{ middle }}">{{ middle }}</a></li>
                                {% else %}
                                    <li><a href="?p={{ middle }}">{{ middle }}</a></li>
                                {% endifequal %}
                            {% endfor %}
                            {% if page.has_next %}
                                <li>
                                    <a href="?p={{ page.next_page_number }}" aria-label="Next">
                                        <span aria-hidden="true">下一页</span>
                                    </a>
                                </li>
                            {% else %}
                                <li class="disabled">
                                    <a href="#" aria-label="Next">
                                        <span aria-hidden="true">下一页</span>
                                    </a>
                                </li>
                            {% endif %}

                        </ul>
                    </nav>
                    <!-- 文章分页结束 -->
                </div>
            </div>
            <!-- 中间结束 -->

            <!-- 右侧开始 -->
            <div class="col-md-3">
                <div class="panel panel-primary">
                    <div class="panel-heading">博主介绍</div>
                    <div class="panel-body">
                        <table class="table table-bordered">
                            <tbody>
                            <td>站长</td>
                            <td>张大鹏</td>
                            </tbody>
                            <tbody>
                            <td>微信</td>
                            <td>lxgzhwwx</td>
                            </tbody>
                            <tbody>
                            <td>QQ</td>
                            <td>1156956636</td>
                            </tbody>
                        </table>
                    </div>
                </div>

                <div class="panel panel-primary">
                    <div class="panel-heading">友情链接</div>
                    <div class="panel-body">
{#                        <ul style="list-style: none">#}
                        <ul>
                            <li><a href="#">AI之家</a></li>
                            <li><a href="#">新浪微博</a></li>
                            <li><a href="#">知识星球</a></li>
                            <li><a href="#">知乎</a></li>
                            <li><a href="#">百度</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <!-- 右侧结束 -->
        </div>
    </div>
</div>

<nav class="navbar navbar-inverse navbar-fixed-bottom">
    <!-- 底部开始 -->
    <div class="footer" style="text-align: center; color: white; padding: 10px;">
        <p>理想国真惠玩-张大鹏 2020年12月17日-至今</p>
        <p>备案号：京ICP 6666666</p>
    </div>
    <!-- 底部结束 -->
</nav>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script>
    // 点赞功能
    function clickGood(id) {
        $.get('{% url 'article:good' %}', {id}, function (data) {
            if (data.code === 10000) {
                $("#goodNumSpan" + id).text(data.good_num)
            }
        });
    }
</script>
</body>
</html>